precision highp float;
varying vec2 vUv;
varying float vVertTexture;
uniform float iTime;

uniform sampler2D uv_mid;
uniform sampler2D uv_out;
uniform sampler2D uv_sides;

// #define uTime (iTime/1000.0)            // iTime时间单位是 s 秒; 需要转换
// #define BASE_COLOR csm_DiffuseColor     // 在kokomi.js中替换无效
#define THRESHOLD 0.001

void main() {
    // vec2 movingUV = vUv;
    // 小数精度问题导致卡顿
    float scrolled_v = fract( vUv.y + iTime * 0.5 );
    vec2 movingUV = vec2( vUv.x, scrolled_v );

    // movingUV.y += uTime * 0.5;

    vec2 movingUV_Rotated = vec2( movingUV.y, movingUV.x );
    vec2 vUv_Rotated = vec2( 1.0 - vUv.y, 1.0 - vUv.x );


    vec4 op_ctrl_fog = texture( uv_mid, movingUV );
    // 注意头尾的透明度贴图一定要是固定UV坐标
    vec4 op_ctrl_line = texture( uv_out, movingUV_Rotated );
    vec4 op_ctrl_sides = texture( uv_sides, vUv_Rotated );

    if ( op_ctrl_fog.r < THRESHOLD ) 
        discard;

    if (  op_ctrl_sides.r < THRESHOLD )
        discard;
    

    vec3 _color = vec3( 1.0, 1.0, 1.0);
    gl_FragColor = vec4(_color, op_ctrl_sides.r * op_ctrl_fog.r);
    
    
}